'''dictionary{'team_name': {'total_games': 10, 'wins': 2, 'draw': 3, 'defeats': 1, 'total_score': 9}}'''
def updateTeam(teamName, score, win, defeated):
    if teamName not in teams:
        teams[teamName] = {'total_games': 0, 'wins': 0, 'draw': 0, 'defeats': 0, 'total_score': 0}
    line = teams[teamName]
    line['total_games'] += 1
    if win:
        line['wins'] += 1
        line['total_score'] += 3
    elif defeated:
        line['defeats'] += 1
    else:
        line['draw'] += 1
        line['total_score'] += 1

        #print('>>>', teams)
#n = 3 # Зенит;3;Спартак;1 Спартак;1;ЦСК;1  ЦСК;0;Зенит;2
teams = {}

in_seq = """Зенит;3;Спартак;1
Динамо;1;ЦСК;1
ЦСК;0;Зенит;2"""

#for i in range(n):
for i in in_seq.split('\n'):
    game = i.split(';')
    team_name1 = game[0]
    score1 = int(game[1])
    team_name2 = game[2]
    score2 = int(game[3])

#    game = input().split(';')

    updateTeam(team_name1, score1, score1 > score2, score1 < score2)
    updateTeam(team_name2, score2, score1 < score2, score1 > score2)

final_result = ''
for teamName, line in teams.items():
    final_result = teamName +':' + str(line['total_games']) + ' ' + str(line['wins']) +' ' + str(line['draw']) + ' ' + str(line['defeats']) + ' '+ str(line['total_score'])
    print(final_result)


#Победа - 3 чока, поражение - 0 очков, ничья - 1
#Команда: всего игр, побед, ничьих, поражений, всего очков
#Зенит: 2 2 0 0 6
#ЦСКА: 2 0 1 1 1
#Спартак: 2 0 1 1 1







'''one_score = []
three_score = []
null_score = []
count_game = 0
for i in team_list:
        if int(i[1]) > int(i[3]):
            three_score.append(i[0])
            null_score.append(i[2])
        elif int(i[1]) == int(i[3]):
            one_score.append(i[0])
            one_score.append(i[2])
        elif int(i[1]) < int(i[3]):
            three_score.append(i[2])
            null_score.append(i[0])
print('one_score>>>', one_score)
print('null_score>>>', null_score)
print('three_score>>>>', three_score)'''


